import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'

import Pages from 'vite-plugin-pages'
import Layouts from 'vite-plugin-vue-layouts';

import { ViteAliases } from 'vite-aliases'

import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'

import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

import WindiCSS from 'vite-plugin-windicss'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    Components({
      resolvers: [
        IconsResolver(),
        ElementPlusResolver()
      ]
    }),
    AutoImport({
      resolvers: [
        IconsResolver(),
        ElementPlusResolver()
      ],
      // targets to transform
      include: [
        /\.[tj]sx?$/,
        /\.vue$/,
        /\.vue\?vue/,
        /\.md$/,
      ],
      // 全局注册导入插件
      imports: [
        // 插件预设支持导入的api
        'vue',
        'vue-router'
        // 自定义导入的api
      ],
      // Generate corresponding .eslintrc-auto-import.json file.
      // eslint globals Docs - https://eslint.org/docs/user-guide/configuring/language-options#specifying-globals
      eslintrc: {
        enabled: false, // Default `false`
        filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
        globalsPropValue: true, // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
      },
      // Filepath to generate corresponding .d.ts file.
      // Defaults to './auto-imports.d.ts' when `typescript` is installed locally.
      // Set `false` to disable.
      dts: './auto-imports.d.ts',
    }),
    Pages(),
    Layouts(),
    ViteAliases(),
    Icons(),
    WindiCSS(),
  ],
  server: {
    host: "0.0.0.0",
    port: 8080
  }
})